<?php
namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Model\OperationLogs;
use App\Model\Angerbird;

class AngerbirdController extends BaseController
{
    protected $model = null;

    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->model = new Angerbird();
    }

    //愤怒的小鸟游戏配置获取
    public function angerbirdGetConfig(Request $request){
        $res = $this->model->angerbirdGetConfig($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //愤怒的小鸟配置修改
    public function angerbirdUpdateConfig(Request $request){
        $res = $this->model->angerbirdUpdateConfig($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '愤怒的小鸟配置修改');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //愤怒的小鸟兑换商店列表
    public function angerbirdGetShopList(Request $request){
        $res = $this->model->angerbirdGetShopList($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //愤怒的小鸟新增商店
    public function angerbirdAddShop(Request $request){
        $res = $this->model->angerbirdAddShop($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '愤怒的小鸟新增商店');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //愤怒的小鸟修改商店
    public function angerbirdUpdateShop(Request $request){
        $res = $this->model->angerbirdUpdateShop($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '愤怒的小鸟修改商店');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

}
